package com.dgz.system.test;

import com.dgz.common.redis.service.RedisService;
import com.dgz.system.domain.sysuser.SysUser;
import com.dgz.system.test.domain.ValidationDTO;
import com.dgz.system.test.service.ItestService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: DongGuoZhen
 * @Date: 2024/12/02/15:43
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/test")
public class testController {


    @Autowired
    private RedisService redisService;
    @Resource
    private ItestService testService;

    @RequestMapping("/hello")
    public List<?> hello(){
        return testService.list();
    }


    @GetMapping("/hello2")
    public String hello2() {
        log.info("我是info");
        log.error("我是error");
        return "log test";
    }


    @GetMapping("/hello3")
    public String hello3() {
        SysUser user = new SysUser();
        user.setUserId(123L);
        user.setUserAccount("test11111111111111");
        user.setPassword("123456");

        redisService.setCacheObject("user",user);
        SysUser user1 = redisService.getCacheObject("user", SysUser.class);
        return user1.toString();

    }

    @GetMapping("/validation")
    public String validation(@Validated ValidationDTO validationDTO) {


        return "validation test";
    }
}
